package org.example.leetCode;

/**
 * @Author Qinkai
 * @Description TODO $
 * @Date $ 2021-09-22$
 * @Param $
 * @return $
 **/
public class CountBits {
    public static void main(String[] args) {
        CountBits countBits = new CountBits();
        int[] ints = countBits.countBits(5);
        System.out.println(ints);
    }

    public int[] countBits(int n) {
        int[] res = new int[n + 1];
        for (int i = 0; i <= n / 2; i++) {
            res[i * 2] = res[i];
            if (i * 2 + 1 <= n) {
                res[i * 2 + 1] = res[i] + 1;
            }
        }
        return res;
    }
}
